package cn.edu.hunau.java.week02.day03;

import org.junit.Test;

import java.util.Arrays;
import java.util.Random;

public class CardTest {
    @Test
    public void Test01() {
        Card c1 = new Card(0, 0);
        Card c2 = new Card(Card.SUIT_HEITAO, Card.SUIT_HEITAO);
        System.out.println(c1);
        System.out.println(c2);

    }

    public Card[] newCards(){
        Card[] cards = new Card[54];
        int index = 0;
        for (int rank = Card.RANK_3; rank <= Card.RANK_2; rank++) {
             for (int suit = Card.SUIT_HEITAO; suit <= Card.SUIT_FANGKUAI; suit++) {
                 cards[index++] = new Card(suit, rank);
             }
        }
    cards[index++] = new Card(Card.SUIT_KUAN, Card.RANK_THREE);
    cards[index++] = new Card(Card.SUIT_KUAN, Card.RANK_FOUR);
        Random r=new Random();
        for(int i=cards.length-1;i>=0;i--){
            int j=r.nextInt(i);
            Card temp=cards[j];
            cards[j]=cards[j+1];
            cards[j+1]=temp;
        }
     return cards;
    }

    @Test
    public void Test02() {
        Player [] players=new Player[3];
        players[0]=new Player("张飞");
        players[1]=new Player("关羽");
        players[2]=new Player("刘备");

        Card[] cards=newCards();
        for(int i=0;i<players.length;i++){
            players[i&3].addCard(cards[i]);
        }
        for(Player p:players){
            System.out.println(p);
        }
    }
}
